package org.bultreebank.index.schema.management.interfaces;


import java.util.Properties;

import org.w3c.dom.Document;

/**
 * Contains methods for index schema manipulations
 * @author Aneliya Tincheva
 *
 */
public interface IndexingSchemaManager
{
	public String getLang(String indexID) throws Exception; 
	/**
	 * Returns the index repository path registered
	 * @return
	 */
	public String getIndexRepositoryPath();
	
	/**
	 * Returns the normalized indexing schema document relevant
	 * for the specified index
	 * @param realIndexID - the user defined index ID
	 * @return
	 * @throws Exception
	 */
	public Document getIndexSchema(String realIndexID) throws Exception;
	
	/**
	 * Normalizes and adds the normalized index document to 
	 * the index repository.
	 * @param indexSchema - user defined indexing schema 
	 * @return
	 * @throws Exception
	 */
	public String addIndexSchema(Document indexSchema) throws Exception;
	
	/**
	 * 
	 * @param realIndexID - user defined indexing schema document 
	 * @param restrictive - boolean variable used for specifying the deletion
	 * mode (true = if there are any documents added to the specified index 
	 * it wouldn't be deleted; false = otherwise)
	 * @return
	 * @throws Exception
	 */
	public void removeIndexSchema (String realIndexID, boolean restrictive) throws Exception;
	
	/**
	 * Returns the system generated index ID for the specified user defined
	 * index ID
	 * @param userIndexID
	 * @return
	 * @throws Exception
	 */
	public String getInternalIndexID(String userIndexID) throws Exception;
	
	/**
	 * Returns the user defined index ID corresponding to the specified 
	 * internal index ID
	 * @param internalIndexID
	 * @return
	 * @throws Exception
	 */
	public String getUserIndexID(String internalIndexID) throws Exception;
	
	/**
	 * Returns a Properties object, representing the 
	 * user defined - system generated index IDs
	 * @return
	 */
	public Properties getAllUser_SystemIndexes();
	
	/**
	 * Returns a Properties object, representing the 
	 * system generated - user defined index IDs
	 * @return
	 */
	public Properties getAllSystem_UserIndexes();
	
	/**
	 * Returns true if there are any documents added to the index and false 
	 * otherwise
	 * @param realIndexID - user defined index ID
	 * @return
	 * @throws Exception
	 */
	public boolean isIndexEmpty(String realIndexID)throws Exception;
	
	/**
	 * Returns the search engine repository path
	 * @return
	 */
	public String getSearchEngineRepositoryPath();
	
	/**
	 * Returns true if the specified index exists in the index repository 
	 * @param realIndexID - user defined index ID
	 * @return
	 * @throws Exception
	 */
	public boolean ifIndexExists(String realIndexID) throws Exception;
	
	/**
	 * Updates (created new normalized document and saves it in the Index 
	 * Repository) the index schema document for the specified index
	 * @param indexSchemaDoc - user defined index schema document
	 * @param realIndexID
	 * @throws Exception
	 */
	public void updateIndexSchema(Document indexSchemaDoc, 
			String realIndexID) throws Exception;
	
}
